/***************************************************************************
 *   Copyright (C) 2006 by UC Davis Stahlberg Laboratory                   *
 *   HStahlberg@ucdavis.edu                                                *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#ifndef LOGVIEWER_H  // conditional compilation for protection
#define LOGVIEWER_H

#include <qwidget.h>  // qt widget class library
#include <qstring.h>  // qt string class library
#include <qgridlayout.h>  // qt layout class library
#include <qtextedit.h>  // qt text edit class library
#include <qtextdocument.h>  // qt text document class library

#include "LogBrowserCommons.h"  // common definitions for the whole project
#include "LogFileReader.h"  // log file reader class library

class LogViewer;  // forward declaration
/***************************************************************************
 * This class implements the widget that contains the text viewer display  *
 * area that contains the log file contents.  It contains a text viewer    *
 * along with a text document.  It is simply the widget that contains all  *
 * of the gui elements for the viewer but gives the text document to the   *
 * reader so the reader will take care of all the reading work from the    *
 * log file and output it via a text document cursor pointer given by this *
 * viewer.                                                                 *
 ***************************************************************************/
class LogViewer : public QWidget
{
    Q_OBJECT  // qt object macro

    private:
    QFont *text_font;
    QString log_file_name;  // the name of the log file the viewer is associated with
    QTextEdit *text_area_ptr;  // the viewer text display area where log file text is displayed
    QTextDocument *text_document_ptr;  // the underlying text document
    QGridLayout *viewer_layout;  // the layout for this widget class
    LogFileReader *reader;  // the actual underlying log file reader class

    VerbosityLevel currentVLevel;

    public:
    LogViewer(QString file_name="", VerbosityLevel level=level_one, QWidget *parent=NULL);  // constructor for the viewer
    ~LogViewer();  // destructor and garbage collector for the viewer
    void startLogRead();  // start to read the log file the widget is associated with
    void verbosityChange(VerbosityLevel verb_level);  // change the verbosity level of the viewer

    public slots:
    void updateViewer();  // update the viewer with the latest content from the log file
};

#endif
